G = input('是否退出程序(y/n)')
while True :
  try:
    if G == 'n':
          a = input("输入你的性别（man/woman)：")
          b = eval(input("请输入你的年龄:"))
          c = eval(input("请输入你的体重(kg):"))
          d = eval(input("请输入你的身高(cm):"))
          x = 0
          b,c,d == int  #??????????????????
          if a == 'man' or a == '男' or a == 'nan':
              e = 67 + 13.7 * c + 5 * d - 6.9 * b
              print("你的基础代谢率是{:.2f}大卡".format(e))
              x = x+1
              z = open('C:/Users/wsx/Desktop/Python:/第{}次的bmr值.txt'.format(x), 'w')
              z.write("性别:{}"'\n'"年龄:{}"'\n'"身高(cm):{}"'\n'"体重(kg):{}"'\n'"新陈代谢率(大卡):{:.2f}".format(a, b, d, c,e ))
              z.close()
              print('已成功运行{}次程序'.format(x))
          elif a == 'woman'or a =='男' or a == 'nan':
              f = 661 + 9.6 * c + 1.72 * d - 6.9 * b
              print("你的基础代谢率是{:.2f}大卡".format(f))
              x = x+1
              z = open('C:/Users/wsx/Desktop/Python/第{}次的bmr值.txt'.format(x), 'w')
              z.write("性别:{}"'\n'"年龄:{}"'\n'"身高(cm):{}"'\n'"体重(kg):{}"'\n'"新陈代谢率(大卡):{:.2f}".format(a, b, d, c,f ))
              z.close()
              print('已成功运行{}次程序'.format(x))
          print()
          G = input('是否退出程序(y/n)')
    elif G == 'y' :
        print('咱不运行了噢')
        break
  except Exception:
    print('输入错误无法运行')
    print()
    G = input('是否退出程序(y/n)')